package com.baizw.cultivation.common.command;

import com.baizw.cultivation.module.admin.entity.DictDataEntity;
import com.baizw.cultivation.module.admin.entity.DictTypeEntity;
import com.baizw.cultivation.module.admin.service.DictDataService;
import com.baizw.cultivation.module.admin.service.DictTypeService;
import com.baizw.cultivation.util.DictUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 初始化缓存
 *
 * @author 剧终1204
 * @version V1.0
 * @date 2020年12月07日 16:51
 */
@Component
public class RedisInit implements CommandLineRunner {
	
//	@Autowired
//	private DictTypeService typeService;
//	@Autowired
//	private DictDataService dataService;
	
	@Override
	public void run(String... args) throws Exception {
//		List<DictTypeEntity> dictTypeList = typeService.list();
//		for (DictTypeEntity dictType : dictTypeList) {
//			LambdaQueryWrapper<DictDataEntity> queryWrapper = Wrappers.<DictDataEntity>lambdaQuery().eq(DictDataEntity::getDictType, dictType.getDictType());
//			List<DictDataEntity> dictDataEntityList = dataService.list(queryWrapper);
//			DictUtils.setDictCache(dictType.getDictType(), dictDataEntityList);
//		}
	}
}
